
/*
'===============================================================================
'  Generated From - CSharp_dOOdads_BusinessEntity.vbgen
' 
'  ** IMPORTANT  ** 
'  How to Generate your stored procedures:
' 
'  SQL        = SQL_StoredProcs.vbgen
'  ACCESS     = Access_StoredProcs.vbgen
'  ORACLE     = Oracle_StoredProcs.vbgen
'  FIREBIRD   = FirebirdStoredProcs.vbgen
'  POSTGRESQL = PostgreSQL_StoredProcs.vbgen
'
'  The supporting base class SqlClientEntity is in the Architecture directory in "dOOdads".
'  
'  This object is 'abstract' which means you need to inherit from it to be able
'  to instantiate it.  This is very easilly done. You can override properties and
'  methods in your derived class, this allows you to regenerate this class at any
'  time and not worry about overwriting custom code. 
'
'  NEVER EDIT THIS FILE.
'
'  public class YourObject :  _YourObject
'  {
'
'  }
'
'===============================================================================
*/

// Generated by MyGeneration Version # (1.3.0.3)

using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using System.Collections.Specialized;

using MyGeneration.dOOdads;

namespace ShopOnline.DAL
{
    public abstract class _RelatedLinks : SqlClientEntity
    {
        public _RelatedLinks()
        {
            this.QuerySource = "RelatedLinks";
            this.MappingName = "RelatedLinks";

        }

        //=================================================================
        //  public Overrides void AddNew()
        //=================================================================
        //
        //=================================================================
        public override void AddNew()
        {
            base.AddNew();

        }


        public override void FlushData()
        {
            this._whereClause = null;
            this._aggregateClause = null;
            base.FlushData();
        }

        //=================================================================
        //  	public Function LoadAll() As Boolean
        //=================================================================
        //  Loads all of the records in the database, and sets the currentRow to the first row
        //=================================================================
        public bool LoadAll()
        {
            ListDictionary parameters = null;

            return base.LoadFromSql("[" + this.SchemaStoredProcedure + "proc_RelatedLinksLoadAll]", parameters);
        }

        //=================================================================
        // public Overridable Function LoadByPrimaryKey()  As Boolean
        //=================================================================
        //  Loads a single row of via the primary key
        //=================================================================
        public virtual bool LoadByPrimaryKey(int ID)
        {
            ListDictionary parameters = new ListDictionary();
            parameters.Add(Parameters.ID, ID);


            return base.LoadFromSql("[" + this.SchemaStoredProcedure + "proc_RelatedLinksLoadByPrimaryKey]", parameters);
        }

        #region Parameters
        protected class Parameters
        {

            public static SqlParameter ID
            {
                get
                {
                    return new SqlParameter("@ID", SqlDbType.Int, 0);
                }
            }

            public static SqlParameter Title
            {
                get
                {
                    return new SqlParameter("@Title", SqlDbType.NVarChar, 50);
                }
            }

            public static SqlParameter Description
            {
                get
                {
                    return new SqlParameter("@Description", SqlDbType.NVarChar, 150);
                }
            }

            public static SqlParameter URL
            {
                get
                {
                    return new SqlParameter("@URL", SqlDbType.NVarChar, 1073741823);
                }
            }

        }
        #endregion

        #region ColumnNames
        public class ColumnNames
        {
            public const string ID = "ID";
            public const string Title = "Title";
            public const string Description = "Description";
            public const string URL = "URL";

            static public string ToPropertyName(string columnName)
            {
                if (ht == null)
                {
                    ht = new Hashtable();

                    ht[ID] = _RelatedLinks.PropertyNames.ID;
                    ht[Title] = _RelatedLinks.PropertyNames.Title;
                    ht[Description] = _RelatedLinks.PropertyNames.Description;
                    ht[URL] = _RelatedLinks.PropertyNames.URL;

                }
                return (string)ht[columnName];
            }

            static private Hashtable ht = null;
        }
        #endregion

        #region PropertyNames
        public class PropertyNames
        {
            public const string ID = "ID";
            public const string Title = "Title";
            public const string Description = "Description";
            public const string URL = "URL";

            static public string ToColumnName(string propertyName)
            {
                if (ht == null)
                {
                    ht = new Hashtable();

                    ht[ID] = _RelatedLinks.ColumnNames.ID;
                    ht[Title] = _RelatedLinks.ColumnNames.Title;
                    ht[Description] = _RelatedLinks.ColumnNames.Description;
                    ht[URL] = _RelatedLinks.ColumnNames.URL;

                }
                return (string)ht[propertyName];
            }

            static private Hashtable ht = null;
        }
        #endregion

        #region StringPropertyNames
        public class StringPropertyNames
        {
            public const string ID = "s_ID";
            public const string Title = "s_Title";
            public const string Description = "s_Description";
            public const string URL = "s_URL";

        }
        #endregion

        #region Properties

        public virtual int ID
        {
            get
            {
                return base.Getint(ColumnNames.ID);
            }
            set
            {
                base.Setint(ColumnNames.ID, value);
            }
        }

        public virtual string Title
        {
            get
            {
                return base.Getstring(ColumnNames.Title);
            }
            set
            {
                base.Setstring(ColumnNames.Title, value);
            }
        }

        public virtual string Description
        {
            get
            {
                return base.Getstring(ColumnNames.Description);
            }
            set
            {
                base.Setstring(ColumnNames.Description, value);
            }
        }

        public virtual string URL
        {
            get
            {
                return base.Getstring(ColumnNames.URL);
            }
            set
            {
                base.Setstring(ColumnNames.URL, value);
            }
        }


        #endregion

        #region String Properties

        public virtual string s_ID
        {
            get
            {
                return this.IsColumnNull(ColumnNames.ID) ? string.Empty : base.GetintAsString(ColumnNames.ID);
            }
            set
            {
                if (string.Empty == value)
                    this.SetColumnNull(ColumnNames.ID);
                else
                    this.ID = base.SetintAsString(ColumnNames.ID, value);
            }
        }

        public virtual string s_Title
        {
            get
            {
                return this.IsColumnNull(ColumnNames.Title) ? string.Empty : base.GetstringAsString(ColumnNames.Title);
            }
            set
            {
                if (string.Empty == value)
                    this.SetColumnNull(ColumnNames.Title);
                else
                    this.Title = base.SetstringAsString(ColumnNames.Title, value);
            }
        }

        public virtual string s_Description
        {
            get
            {
                return this.IsColumnNull(ColumnNames.Description) ? string.Empty : base.GetstringAsString(ColumnNames.Description);
            }
            set
            {
                if (string.Empty == value)
                    this.SetColumnNull(ColumnNames.Description);
                else
                    this.Description = base.SetstringAsString(ColumnNames.Description, value);
            }
        }

        public virtual string s_URL
        {
            get
            {
                return this.IsColumnNull(ColumnNames.URL) ? string.Empty : base.GetstringAsString(ColumnNames.URL);
            }
            set
            {
                if (string.Empty == value)
                    this.SetColumnNull(ColumnNames.URL);
                else
                    this.URL = base.SetstringAsString(ColumnNames.URL, value);
            }
        }


        #endregion

        #region Where Clause
        public class WhereClause
        {
            public WhereClause(BusinessEntity entity)
            {
                this._entity = entity;
            }

            public TearOffWhereParameter TearOff
            {
                get
                {
                    if (_tearOff == null)
                    {
                        _tearOff = new TearOffWhereParameter(this);
                    }

                    return _tearOff;
                }
            }

            #region WhereParameter TearOff's
            public class TearOffWhereParameter
            {
                public TearOffWhereParameter(WhereClause clause)
                {
                    this._clause = clause;
                }


                public WhereParameter ID
                {
                    get
                    {
                        WhereParameter where = new WhereParameter(ColumnNames.ID, Parameters.ID);
                        this._clause._entity.Query.AddWhereParameter(where);
                        return where;
                    }
                }

                public WhereParameter Title
                {
                    get
                    {
                        WhereParameter where = new WhereParameter(ColumnNames.Title, Parameters.Title);
                        this._clause._entity.Query.AddWhereParameter(where);
                        return where;
                    }
                }

                public WhereParameter Description
                {
                    get
                    {
                        WhereParameter where = new WhereParameter(ColumnNames.Description, Parameters.Description);
                        this._clause._entity.Query.AddWhereParameter(where);
                        return where;
                    }
                }

                public WhereParameter URL
                {
                    get
                    {
                        WhereParameter where = new WhereParameter(ColumnNames.URL, Parameters.URL);
                        this._clause._entity.Query.AddWhereParameter(where);
                        return where;
                    }
                }


                private WhereClause _clause;
            }
            #endregion

            public WhereParameter ID
            {
                get
                {
                    if (_ID_W == null)
                    {
                        _ID_W = TearOff.ID;
                    }
                    return _ID_W;
                }
            }

            public WhereParameter Title
            {
                get
                {
                    if (_Title_W == null)
                    {
                        _Title_W = TearOff.Title;
                    }
                    return _Title_W;
                }
            }

            public WhereParameter Description
            {
                get
                {
                    if (_Description_W == null)
                    {
                        _Description_W = TearOff.Description;
                    }
                    return _Description_W;
                }
            }

            public WhereParameter URL
            {
                get
                {
                    if (_URL_W == null)
                    {
                        _URL_W = TearOff.URL;
                    }
                    return _URL_W;
                }
            }

            private WhereParameter _ID_W = null;
            private WhereParameter _Title_W = null;
            private WhereParameter _Description_W = null;
            private WhereParameter _URL_W = null;

            public void WhereClauseReset()
            {
                _ID_W = null;
                _Title_W = null;
                _Description_W = null;
                _URL_W = null;

                this._entity.Query.FlushWhereParameters();

            }

            private BusinessEntity _entity;
            private TearOffWhereParameter _tearOff;

        }

        public WhereClause Where
        {
            get
            {
                if (_whereClause == null)
                {
                    _whereClause = new WhereClause(this);
                }

                return _whereClause;
            }
        }

        private WhereClause _whereClause = null;
        #endregion

        #region Aggregate Clause
        public class AggregateClause
        {
            public AggregateClause(BusinessEntity entity)
            {
                this._entity = entity;
            }

            public TearOffAggregateParameter TearOff
            {
                get
                {
                    if (_tearOff == null)
                    {
                        _tearOff = new TearOffAggregateParameter(this);
                    }

                    return _tearOff;
                }
            }

            #region AggregateParameter TearOff's
            public class TearOffAggregateParameter
            {
                public TearOffAggregateParameter(AggregateClause clause)
                {
                    this._clause = clause;
                }


                public AggregateParameter ID
                {
                    get
                    {
                        AggregateParameter aggregate = new AggregateParameter(ColumnNames.ID, Parameters.ID);
                        this._clause._entity.Query.AddAggregateParameter(aggregate);
                        return aggregate;
                    }
                }

                public AggregateParameter Title
                {
                    get
                    {
                        AggregateParameter aggregate = new AggregateParameter(ColumnNames.Title, Parameters.Title);
                        this._clause._entity.Query.AddAggregateParameter(aggregate);
                        return aggregate;
                    }
                }

                public AggregateParameter Description
                {
                    get
                    {
                        AggregateParameter aggregate = new AggregateParameter(ColumnNames.Description, Parameters.Description);
                        this._clause._entity.Query.AddAggregateParameter(aggregate);
                        return aggregate;
                    }
                }

                public AggregateParameter URL
                {
                    get
                    {
                        AggregateParameter aggregate = new AggregateParameter(ColumnNames.URL, Parameters.URL);
                        this._clause._entity.Query.AddAggregateParameter(aggregate);
                        return aggregate;
                    }
                }


                private AggregateClause _clause;
            }
            #endregion

            public AggregateParameter ID
            {
                get
                {
                    if (_ID_W == null)
                    {
                        _ID_W = TearOff.ID;
                    }
                    return _ID_W;
                }
            }

            public AggregateParameter Title
            {
                get
                {
                    if (_Title_W == null)
                    {
                        _Title_W = TearOff.Title;
                    }
                    return _Title_W;
                }
            }

            public AggregateParameter Description
            {
                get
                {
                    if (_Description_W == null)
                    {
                        _Description_W = TearOff.Description;
                    }
                    return _Description_W;
                }
            }

            public AggregateParameter URL
            {
                get
                {
                    if (_URL_W == null)
                    {
                        _URL_W = TearOff.URL;
                    }
                    return _URL_W;
                }
            }

            private AggregateParameter _ID_W = null;
            private AggregateParameter _Title_W = null;
            private AggregateParameter _Description_W = null;
            private AggregateParameter _URL_W = null;

            public void AggregateClauseReset()
            {
                _ID_W = null;
                _Title_W = null;
                _Description_W = null;
                _URL_W = null;

                this._entity.Query.FlushAggregateParameters();

            }

            private BusinessEntity _entity;
            private TearOffAggregateParameter _tearOff;

        }

        public AggregateClause Aggregate
        {
            get
            {
                if (_aggregateClause == null)
                {
                    _aggregateClause = new AggregateClause(this);
                }

                return _aggregateClause;
            }
        }

        private AggregateClause _aggregateClause = null;
        #endregion

        protected override IDbCommand GetInsertCommand()
        {

            SqlCommand cmd = new SqlCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "[" + this.SchemaStoredProcedure + "proc_RelatedLinksInsert]";

            CreateParameters(cmd);

            SqlParameter p;
            p = cmd.Parameters[Parameters.ID.ParameterName];
            p.Direction = ParameterDirection.Output;

            return cmd;
        }

        protected override IDbCommand GetUpdateCommand()
        {

            SqlCommand cmd = new SqlCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "[" + this.SchemaStoredProcedure + "proc_RelatedLinksUpdate]";

            CreateParameters(cmd);

            return cmd;
        }

        protected override IDbCommand GetDeleteCommand()
        {

            SqlCommand cmd = new SqlCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "[" + this.SchemaStoredProcedure + "proc_RelatedLinksDelete]";

            SqlParameter p;
            p = cmd.Parameters.Add(Parameters.ID);
            p.SourceColumn = ColumnNames.ID;
            p.SourceVersion = DataRowVersion.Current;


            return cmd;
        }

        private IDbCommand CreateParameters(SqlCommand cmd)
        {
            SqlParameter p;

            p = cmd.Parameters.Add(Parameters.ID);
            p.SourceColumn = ColumnNames.ID;
            p.SourceVersion = DataRowVersion.Current;

            p = cmd.Parameters.Add(Parameters.Title);
            p.SourceColumn = ColumnNames.Title;
            p.SourceVersion = DataRowVersion.Current;

            p = cmd.Parameters.Add(Parameters.Description);
            p.SourceColumn = ColumnNames.Description;
            p.SourceVersion = DataRowVersion.Current;

            p = cmd.Parameters.Add(Parameters.URL);
            p.SourceColumn = ColumnNames.URL;
            p.SourceVersion = DataRowVersion.Current;


            return cmd;
        }
    }
}


